﻿@model Website.Models.Category

@{
    ViewBag.Title = "CreateSubCategory";
}

<script type="text/javascript">
    $(document).ready(function () {
        getCategoryCode();
    });

    function getCategoryCode() {
        $('#CategoryName').change(function () {
            var categoryName = $(this).val();
            var arr = categoryName.split(' ');
            var s = '';
            for (var i = 0; i < arr.length; i++) {
                s += arr[i].toString().toUpperCase()[0];
            }
            $('#Code').val(s).text(s);
        });
    }
</script>

<h2>Create Sub Category</h2>

<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>

@using (Html.BeginForm()) {
    @Html.ValidationSummary(true)
    <fieldset>
        <legend>Category</legend>
        
        <div class="display-label">Gender</div>
        <div class="display-field">
            @Html.DisplayFor(model => model.Gender)
            @Html.HiddenFor(model=>model.Gender)
        </div>
        
        <div class="display-label">Danh Mục SP Cha</div>
        <div class="display-field">
            @Html.DisplayFor(model => model.ParentCategory.CategoryName)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.CategoryName)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.CategoryName)
            @Html.ValidationMessageFor(model => model.CategoryName)
        </div>
        
        @Html.HiddenFor(model=>model.ParentCategoryID)

        @*<div class="editor-label">
            @Html.LabelFor(model => model.ParentCategoryID, "ParentCategory")
        </div>
        <div class="editor-field">
            @Html.DropDownList("ParentCategoryID", String.Empty)
            @Html.ValidationMessageFor(model => model.ParentCategoryID)
        </div>*@

        <div class="editor-label">
            @Html.LabelFor(model => model.Code)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Code)
            @Html.ValidationMessageFor(model => model.Code)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Display)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Display)
            @Html.ValidationMessageFor(model => model.Display)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Index)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Index)
            @Html.ValidationMessageFor(model => model.Index)
        </div>

        <p>
            <input type="submit" value="Create" />
        </p>
    </fieldset>
}

<div>
    @Html.ActionLink("Back to List", "Index")
</div>
